package cn.zf233.xcloud.commom.enums;

/**
 * Created by zf233 on 2020/1/30
 * 用户来源
 */
public enum UserSourceENUM {

    EMAIL_USER("邮箱用户", 0, "email"),
    PHONE_USER("手机用户", 1, "phone"),
    QQ_USER("QQ用户", 2, "qq");

    private final String describe;
    private final Integer code;
    private final String key;

    public static UserSourceENUM exists(Integer type) {
        for (UserSourceENUM value : values()) {
            if (value.getCode().equals(type)) {
                return value;
            }
        }
        return null;
    }

    public static String getUserTypeName(Integer type) {
        for (UserSourceENUM value : values()) {
            if (value.getCode().equals(type)) {
                return value.getDescribe();
            }
        }
        return "未知";
    }

    UserSourceENUM(String describe, Integer code, String key) {
        this.describe = describe;
        this.code = code;
        this.key = key;
    }

    public String getDescribe() {
        return describe;
    }

    public Integer getCode() {
        return code;
    }

    public String getKey() {
        return key;
    }
}